#!/bin/bash

show_all_vlan() {
  sudo cat /proc/net/vlan/config | awk 'NR > 2'
  sudo cat /proc/net/vlan/config | awk 'NR > 2' >> config_vrf_log.txt 2>&1
}

echo "============================= cat_vlan_vrf start =============================" >> config_vrf_log.txt 2>&1
if (( $# < 1 )); then
  show_all_vlan
else
  if [ $1 == "all" ]; then
    show_all_vlan
  else
    sudo cat /proc/net/vlan/config | grep -w $1
    sudo cat /proc/net/vlan/config | grep -w $1 >> config_vrf_log.txt 2>&1
    if [ $? -ne 0 ]; then
      echo "No such VLAN $1" >> config_vrf_log.txt 2>&1
      echo "faild"
      exit 1
    fi
    exit 0
  fi
fi
